import {timer} from '@/utils'

import './index.less'

function OrderItem(props) {
  const renderStatus = (val) => {
    if (val == 1) {
      return <div className='status yellow'>待支付</div>
    } else if (val == 2) {
      return <div className='status green'>已支付</div>
    } else if (val == 3) {
      return <div className='status red'>已取消</div>
    }
  }

  return (
    <div className='order-item' onClick={() => {
      props.handleClick(props?.data?.id)
    }}>
      <h1 className='title'>订单信息</h1>
      <div className='info'>
        <img
          src={props?.data?.houseHouseInfoPictures ? props?.data?.houseHouseInfoPictures.split('|')[0] : require('@/assets/blank.png')}/>
        <div>
          <p className='houseName'>房屋标题：{props?.data?.houseName}</p>
          <p className='owner'>房东：{props?.data?.houseOwnerNickName}</p>
          <p className='amount'>金额：{props?.data?.amount}</p>
        </div>
      </div>
      <p className='createTime'><span>创建时间：</span>{timer(props?.data?.createdAt)}</p>
      {renderStatus(props?.data?.status)}
    </div>
  )
}

export default OrderItem
